package org.keyuan.dao.impl;

import java.util.List;

import org.hibernate.Query;
import org.keyuan.dao.BuyerDao;
import org.keyuan.entity.Buyer;

public class BuyerDaoImpl extends DaoSupport<Buyer> implements BuyerDao{
	@SuppressWarnings("unchecked")
	public Buyer login(Buyer buyer) {
		String hql="from Buyer b where b.email=? and b.password=?";
		Query query=this.getSession().createQuery(hql);
		query.setString(0, buyer.getEmail());
		query.setString(1, buyer.getPassword());
		List<Buyer> buyers=query.list();
		if(buyers!=null&&buyers.size()>0){
			return buyers.get(0);
		}
		return null;
	}


}
